/**
 * @Author: 陈瑞鹏
 * @Date:   2022-10-17 10:28:08
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-10-18 15:10:27
 */
import mongoose from 'mongoose';

const Schema = mongoose.Schema;
const UserSchema: mongoose.Schema = new Schema({
  openId: { type: String, display: '用户ID', index: true },
  roleId: { type: Number, display: '角色ID', index: true },
  serverId: { type: Number, display: '服务器ID', default: 1, index: true },
  nickName: { type: String, display: '角色昵称', index: true },
  avatar: { type: String, display: '头像' },
  headFrame: { type: Number, display: '头像框' },
  goldCoin: { type: String, display: '金币', default: 0 },
  diamond: { type: Number, display: '钻石', default: 0 },
  status: { type: Boolean, display: '账号状态', default: true },
  statusDesc: { type: String, display: '账号状态描述', },
  forbiddenWords: { type: Boolean, display: '禁言', default: false },
  forbiddenWordsTime: { type: Number, display: '禁言时间(ms)' },
  isOnline: { type: Boolean, display: '是否在线', default: false },
  gate: { type: Number, desc: '关卡', default: 1 },
  power: { type: Number, desc: '战力', default: 0 },
  exp: { type: Number, desc: '经验', default: 0 },
  warTowerId: { type: Number, desc: '出战防御塔id', default: 3006 },
  warLineupArr: { type: Array, desc: '出战英雄数组，位置以下标为准', default: [] },
  sid: { type: String, display: 'socket.id' },
  ecid: { type: Array, display: 'ecid设备码' },
  regIp: { type: String, display: '注册ip' },
  loginIp: { type: String, display: '登录IP' },
  token: { type: String, display: "登录凭证" },
  updateTime: { type: String, display: '更新时间' },
  createTime: { type: String, display: '创建时间' },
}).index({ openId: 1, serverId: 1 }).index({ serverId: 1, status: 1, updateTime: 1 }).index({ status: 1, updateTime: 1 }).index({ roleId: 1, sid: 1 }).index({ status: 1, isOnline: 1, updateTime: 1 });

const User = mongoose.model('User', UserSchema);
export default User;